import React, { lazy } from 'react'
import Store from '../store'

const Login = lazy(() => import('../pages/Login'))
const Err404 = lazy(() => import('../pages/404'))

const Main = lazy(() => import('../pages/Main'))
const Home = lazy(() => import('../pages/Home'))
const AddUser = lazy(() => import('../pages/AddUser'))
const AddTest = lazy(() => import('../pages/AddTest'))


// 二级菜单
export const menuList = [
    {
        path: '/main',
        element: <Main />,
        title: '查看试题',
        auth: '100'
    },
    {
        path: '/adduser',
        element: <AddUser />,
        title: '添加用户',
        auth: '101'
    },
    {
        path: '/addtest',
        element: <AddTest />,
        title: '添加试题',
        auth: '102'
    }
]

// 一级菜单
const routes = [
    {
        path: '/login',
        element: <Login />
    },
    {
        path: '/',
        element: <Home />,
    },
    {
        path: '*',
        element: <Err404 />
    }
]

// 更改菜单
export const changeMenuList = (menuList) => {
    return [
        {
            path: '/login',
            element: <Login />
        },
        {
            path: '/',
            element: <Home />,
            children: menuList
        },
        {
            path: '*',
            element: <Err404 />
        }
    ]
}

export default routes

